package edu.cdnu.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import edu.cdnu.dao.ResourceDao;
import edu.cdnu.pojo.ResourcePojo;
import edu.cdnu.service.ResourceService;

@Service
public class ResourceServiceImpl implements ResourceService{

	@Autowired
	private ResourceDao resourceDao;
	
	@Override
	public void deleteResource(int resourceId) {
		resourceDao.deleteResource(resourceId);
	}
	
	@Override
	public ResourcePojo selectResourceByResourcePojo(ResourcePojo resourcePojo) {
		if(resourcePojo==null) {
			return null;
		}
		return resourceDao.selectResourceByResourcePojo(resourcePojo);
	}
	
	@Override
	public void updateResource(ResourcePojo resourcePojo) {
		if(resourcePojo==null||resourcePojo.getId()==null) {
			return ;
		}
		resourceDao.updateResource(resourcePojo);
	}

	@Override
	public void addResourceDownloadTime(int resourceId) {
		resourceDao.addResourceDownloadTime(resourceId);
	}

	@Override
	public List<ResourcePojo> selectResourceListByCatalogueIdList(List<Integer> catalogueIdList) {
		if(catalogueIdList.size()>0) {
			return resourceDao.selectResourceListByCatalogueIdList(catalogueIdList);
		}
		return null;
	}

	

}
